package com.foreveross.util.redis;


public class JRedisImpl implements RedisService {

	@Override
	public boolean recordProxyIPLog(String clientId, String channel,int num) {
		
		String successKey = RedisKeyTools.retrieveProxyIpSuccessLogKey(channel, clientId);
		String failKey = RedisKeyTools.retrieveProxyIpFailLogKey(channel, clientId);
		ProxyIpJedisTools.counterLog(successKey, num);
		ProxyIpJedisTools.counterLog(failKey, num);
		return true;
	}

//	@Override
//	public boolean persistenceProxyIP(String channel, List<ProxyIpModel> proxyIp) {
//		String key = RedisKeyTools.generateHotPoolKey(channel);
//		Long flag = ProxyIpJedisTools.put(key, proxyIp);
//		return flag ==null?false:true;
//	}

	@Override
	public long countHotpoolSize(String channel) {
		long total = ProxyIpJedisTools.countHotPoolSize(channel);
		return total;
	}

	@Override
	public boolean recordProxyIPLog(String clientId, String channel, int num,
			boolean success) {
		String successKey = RedisKeyTools.retrieveProxyIpSuccessLogKey(channel, clientId);
		String failKey = RedisKeyTools.retrieveProxyIpFailLogKey(channel, clientId);
		if(success){
			ProxyIpJedisTools.counterLog(successKey, num);
		}else{
			ProxyIpJedisTools.counterLog(failKey, num);
		}
		return true;
	}

}
